<!DOCTYPE html>
<html lang="zh">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>时间跳跃</title>
    <style>
        /* 基础样式 */
        * {
            margin: 0;
            padding: 0;
            box-sizing: border-box;
        }
        
        body {
            font-family: 'Arial', sans-serif;
            background: linear-gradient(135deg, #1a1a2e, #16213e, #0f3460);
            color: white;
            height: 100vh;
            display: flex;
            justify-content: center;
            align-items: center;
            overflow: hidden;
            position: relative;
        }
        
        /* 背景动画粒子 */
        .particles {
            position: absolute;
            top: 0;
            left: 0;
            width: 100%;
            height: 100%;
            z-index: 0;
        }
        
        .particle {
            position: absolute;
            background-color: rgba(255, 255, 255, 0.5);
            border-radius: 50%;
            animation: float 15s infinite linear;
        }
        
        @keyframes float {
            0% {
                transform: translateY(0) rotate(0deg);
                opacity: 1;
            }
            100% {
                transform: translateY(-1000px) rotate(720deg);
                opacity: 0;
            }
        }
        
        /* 主容器 */
        .container {
            position: relative;
            z-index: 1;
            text-align: center;
            padding: 2rem;
            background: rgba(0, 0, 0, 0.5);
            border-radius: 20px;
            box-shadow: 0 0 30px rgba(0, 0, 0, 0.5);
            backdrop-filter: blur(10px);
            border: 1px solid rgba(255, 255, 255, 0.1);
            max-width: 800px;
            width: 90%;
            animation: fadeIn 1s ease-out;
        }
        
        @keyframes fadeIn {
            from {
                opacity: 0;
                transform: translateY(50px);
            }
            to {
                opacity: 1;
                transform: translateY(0);
            }
        }
        
        /* 标题样式 */
        .title {
            font-size: 4rem;
            margin-bottom: 2rem;
            background: linear-gradient(to right, #00dbde, #fc00ff);
            -webkit-background-clip: text;
            background-clip: text;
            color: transparent;
            text-shadow: 0 0 20px rgba(0, 219, 222, 0.3);
            font-weight: bold;
            letter-spacing: 2px;
            position: relative;
            display: inline-block;
        }
        
        .title::after {
            content: '';
            position: absolute;
            bottom: -10px;
            left: 0;
            width: 100%;
            height: 3px;
            background: linear-gradient(to right, #00dbde, #fc00ff);
            border-radius: 3px;
            transform: scaleX(0);
            transform-origin: right;
            animation: titleUnderline 2s ease-in-out infinite;
        }
        
        @keyframes titleUnderline {
            0%, 100% {
                transform: scaleX(0);
                transform-origin: right;
            }
            50% {
                transform: scaleX(1);
                transform-origin: left;
            }
        }
        
        /* 按钮容器 */
        .buttons {
            display: flex;
            flex-direction: column;
            gap: 1.5rem;
            margin-top: 3rem;
        }
        
        /* 按钮样式 */
        .btn {
            position: relative;
            padding: 1rem 2rem;
            font-size: 1.2rem;
            color: white;
            border: none;
            border-radius: 50px;
            cursor: pointer;
            overflow: hidden;
            transition: all 0.3s ease;
            z-index: 1;
            font-weight: bold;
            letter-spacing: 1px;
            text-transform: uppercase;
            box-shadow: 0 5px 15px rgba(0, 0, 0, 0.2);
        }
        
        .btn::before {
            content: '';
            position: absolute;
            top: 0;
            left: 0;
            width: 100%;
            height: 100%;
            background: linear-gradient(45deg, #00dbde, #fc00ff, #00dbde);
            background-size: 200% 200%;
            z-index: -1;
            transition: all 0.3s ease;
        }
        
        .btn:hover::before {
            background-position: 100% 100%;
        }
        
        .btn:hover {
            transform: translateY(-5px);
            box-shadow: 0 10px 20px rgba(0, 0, 0, 0.3);
        }
        
        .btn:active {
            transform: translateY(0);
        }
        
        /* 按钮1特殊样式 */
        .btn-start::before {
            background: linear-gradient(45deg, #00dbde, #00b4db);
        }
        
        /* 按钮2特殊样式 */
        .btn-workshop::before {
            background: linear-gradient(45deg, #fc00ff, #b700ff);
        }
        
        /* 按钮3特殊样式 */
        .btn-import::before {
            background: linear-gradient(45deg, #ff8a00, #ff0058);
        }
        
        /* 按钮4特殊样式 - 新增教程按钮 */
        .btn-tutorial::before {
            background: linear-gradient(45deg, #00ff87, #00b4ff);
        }
        
        /* 副标题 */
        .subtitle {
            font-size: 1.2rem;
            margin-bottom: 2rem;
            color: rgba(255, 255, 255, 0.8);
            font-style: italic;
        }
        
        /* 模态框样式 */
        .modal {
            display: none;
            position: fixed;
            top: 0;
            left: 0;
            width: 100%;
            height: 100%;
            background-color: rgba(0, 0, 0, 0.8);
            z-index: 100;
            justify-content: center;
            align-items: center;
        }
        
        .modal-content {
            background: rgba(0, 0, 0, 0.7);
            border-radius: 15px;
            padding: 2rem;
            width: 80%;
            max-width: 700px;
            max-height: 80vh;
            overflow-y: auto;
            border: 1px solid rgba(255, 255, 255, 0.1);
            box-shadow: 0 0 30px rgba(0, 0, 0, 0.7);
            backdrop-filter: blur(10px);
            animation: fadeIn 0.3s ease-out;
        }
        
        .modal-header {
            display: flex;
            justify-content: space-between;
            align-items: center;
            margin-bottom: 1.5rem;
        }
        
        .modal-title {
            font-size: 1.8rem;
            background: linear-gradient(to right, #00ff87, #00b4ff);
            -webkit-background-clip: text;
            background-clip: text;
            color: transparent;
        }
        
        .close-btn {
            background: none;
            border: none;
            color: white;
            font-size: 1.5rem;
            cursor: pointer;
            transition: transform 0.2s;
        }
        
        .close-btn:hover {
            transform: rotate(90deg);
        }
        
        .modal-body {
            line-height: 1.6;
            color: rgba(255, 255, 255, 0.9);
            white-space: pre-line;
        }
        
        /* 响应式设计 */
        @media (max-width: 768px) {
            .title {
                font-size: 3rem;
            }
            
            .btn {
                padding: 0.8rem 1.5rem;
                font-size: 1rem;
            }
            
            .modal-content {
                width: 90%;
                padding: 1.5rem;
            }
            
            .modal-title {
                font-size: 1.5rem;
            }
        }
        
        @media (max-width: 480px) {
            .title {
                font-size: 2.5rem;
            }
            
            .subtitle {
                font-size: 1rem;
            }
            
            .modal-content {
                width: 95%;
                padding: 1rem;
            }
            
            .modal-title {
                font-size: 1.3rem;
            }
        }
    </style>
</head>
<body>
    <!-- 背景粒子 -->
    <div class="particles" id="particles"></div>
    
    <!-- 主内容 -->
    <div class="container">
        <h1 class="title">时间跳跃</h1>
        <p class="subtitle">time jump</p>
        
        <div class="buttons">
            <button class="btn btn-start" id="start-btn">开始游戏</button>
            <button class="btn btn-workshop" id="workshop-btn">创意工坊</button>
            <button class="btn btn-import" id="import-btn">导入关卡</button>
            <button class="btn btn-tutorial" id="tutorial-btn">简易教程</button>
        </div>
    </div>

    <!-- 教程模态框 - 新增 -->
    <div class="modal" id="tutorial-modal">
        <div class="modal-content">
            <div class="modal-header">
                <h2 class="modal-title">简易教程</h2>
                <button class="close-btn" id="close-modal">&times;</button>
            </div>
            <div class="modal-body" id="tutorial-content">
                正在加载教程内容...
            </div>
        </div>
    </div>

    <script>
        // 创建背景粒子
        function createParticles() {
            const particlesContainer = document.getElementById('particles');
            const particleCount = 30;
            
            for (let i = 0; i < particleCount; i++) {
                const particle = document.createElement('div');
                particle.classList.add('particle');
                
                // 随机大小 (2px - 6px)
                const size = Math.random() * 4 + 2;
                particle.style.width = `${size}px`;
                particle.style.height = `${size}px`;
                
                // 随机位置
                particle.style.left = `${Math.random() * 100}%`;
                particle.style.top = `${Math.random() * 100}%`;
                
                // 随机动画延迟和持续时间
                const delay = Math.random() * 15;
                const duration = 10 + Math.random() * 20;
                particle.style.animationDelay = `${delay}s`;
                particle.style.animationDuration = `${duration}s`;
                
                particlesContainer.appendChild(particle);
            }
        }
        
        // 打开游戏窗口
        function openGame() {
                window.location.href = '时间跳跃游戏.html';
        }
        
        // 打开编辑器窗口
        function openEditor() {
            window.open('关卡编辑器.html', '_blank', 'width=1200,height=800');
        }
        
        // 导入关卡功能
        function importLevel() {
            try {
                // 尝试使用Electron或NW.js的API
                if (typeof require === 'function') {
                    const { shell } = require('electron') || require('nw.gui').Shell;
                    shell.showItemInFolder(window.location.pathname);
                    return;
                }
                
                // 尝试使用ActiveXObject (仅IE)
                if (typeof window.ActiveXObject !== 'undefined') {
                    const shell = new ActiveXObject('WScript.Shell');
                    shell.Run('explorer /select,' + window.location.pathname.replace(/\//g, '\\'));
                    return;
                }
                
                // 对于普通浏览器，显示文件输入框
                const input = document.createElement('input');
                input.type = 'file';
                input.accept = '.json,.level,.txt'; // 设置可接受的文件类型
                input.onchange = e => {
                    const file = e.target.files[0];
                    if (file) {
                        const reader = new FileReader();
                        reader.onload = event => {
                            // 这里可以处理读取到的文件内容
                            console.log('导入的关卡文件:', event.target.result);
                            alert(`成功导入关卡文件: ${file.name}`);
                            // 实际应用中，这里应该解析文件内容并加载关卡
                        };
                        reader.readAsText(file);
                    }
                };
                input.click();
                
            } catch (error) {
                console.error('导入关卡失败:', error);
                alert('无法直接打开文件夹。请手动导航到HTML文件所在的文件夹。\n\n路径: ' + window.location.pathname);
            }
        }
        
        const TUTORIAL_CONTENT = `
            时间跳跃 - 游戏教程
            ==================

            1. 开始游戏：点击即开始游戏

	    2. 创意工坊：
		-可以编辑属于你自己的关卡，随后下载关卡数据
		-将下载的关卡文件复制，通过关卡导入功能，找到levels文件后粘贴即可游玩
        `;

        // 显示教程（直接从字符串加载）
        function showTutorial() {
            document.getElementById('tutorial-content').textContent = TUTORIAL_CONTENT;
            document.getElementById('tutorial-modal').style.display = 'flex';
        }

        // 隐藏教程
        function hideTutorial() {
            document.getElementById('tutorial-modal').style.display = 'none';
        }

        // 初始化
        document.addEventListener('DOMContentLoaded', () => {
            createParticles();
            
            // 按钮事件
            document.getElementById('start-btn').addEventListener('click', openGame);
            document.getElementById('workshop-btn').addEventListener('click', openEditor);
            document.getElementById('import-btn').addEventListener('click', importLevel);
            document.getElementById('tutorial-btn').addEventListener('click', showTutorial);
            document.getElementById('close-modal').addEventListener('click', hideTutorial);
            
            // 点击模态框外部关闭
            document.getElementById('tutorial-modal').addEventListener('click', (e) => {
                if (e.target === document.getElementById('tutorial-modal')) {
                    hideTutorial();
                }
            });
            
            // 键盘快捷键（新增4打开教程，ESC关闭）
            document.addEventListener('keydown', (e) => {
                if (e.key === '1' || e.key === 'Enter') openGame();
                else if (e.key === '2') openEditor();
                else if (e.key === '3') importLevel();
                else if (e.key === '4') showTutorial();
                else if (e.key === 'Escape') hideTutorial();
            });
        });
    </script>
</body>
</html>